package com.example.zqr.dto;

import com.example.zqr.pojo.Orderitem;
import com.example.zqr.pojo.Product;
import com.example.zqr.pojo.User;
import lombok.Data;

@Data
public class OrderitemDto extends Orderitem {

    private User user;
    private Product product;

    public OrderitemDto(Orderitem orderitem) {
        setId(orderitem.getId());
        setOrderid(orderitem.getOrderid());
        setUserid(orderitem.getUserid());
        setProid(orderitem.getProid());
        setCurrentunitprice(orderitem.getCurrentunitprice());
        setQuantity(orderitem.getQuantity());
        setTotalprice(orderitem.getTotalprice());
        setStatus(orderitem.getStatus());
        setRevid(orderitem.getRevid());
        setCreatetime(orderitem.getCreatetime());
        setUpdatetime(orderitem.getUpdatetime());
    }

    /**
     * 获取格式化的订单项状态描述。
     * 根据订单项状态码返回对应的状态描述。
     * @return 订单项状态的描述。
     */
    public String getFmtStatus() {
        if (getStatus() == null) {
            return "未评价";
        }
        switch (getStatus()) {
            case 0:
                return "未评价";
            case 1:
                return "已评价";
            default:
                return "";
        }
    }
}
